'use strcit';
//1.引入所需模块
let Koa = require("koa");
let bodyParser = require("koa-bodyparser");
let statics = require("koa-static");
let controller = require('./controllers');
let temp = require('./templating');
let session = require('./session');
let model = require('./model');
let db=require('./db');

//实例化
let app = new Koa();

app.use(session(app));
//第一步：处理静态文件
app.use(statics(__dirname));
//第二步：注册中间件
app.use(bodyParser());
//第三步：模板引擎
app.use(temp)
//第四步：注册自定义路由文件
app.use(controller());


(async () => {
    //模型同步
    // await model.sync();
    console.log('正在加载。。。。');
})();



let port = 4000;
app.listen(port, () => {
    console.log(`http://localhost:${port}`);
});

